package com.ycb.common;

/**
 * @Author ycb 保存数据到当前线程中，用于保存当前用户的id
 * @Version 1.0
 * @Date 2024/10/4 15:59
 */
public class BaseContext {
    private static final ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    public static void setCurrentUserId(long id){
        threadLocal.set(id);
    }

    public static Long getCurrentUserId(){
        try {
            return threadLocal.get();
        } catch (Exception e) {
            return null;
        }

    }
}
